package ${packageName};

<#list importList as item>
import ${item};
</#list>

@Service
public class ${serviceImplName} implements ${serviceName}{
<#assign  mapperVarName = mapperName?substring(0,1)?lower_case+mapperName?substring(1)>
<#assign localVarName = entityClassName?substring(0,1)?lower_case+entityClassName?substring(1)>
    @Autowired
    ${mapperName} ${mapperVarName};

    public List<${entityClassName}> selectAll(){
        return ${mapperVarName}.selectAll();
    }

    public List<${entityClassName}> getSelective(${entityClassName} ${localVarName}){
        return ${mapperVarName}.getSelective(${localVarName});
    }

    public Map<String,Object> selectWithPage(Map map){
        int pageIndex = null==map.get("pageIndex")? 1 : Integer.valueOf(map.get("pageIndex").toString());
        int pageSize = null==map.get("pageSize")? 10 : Integer.valueOf(map.get("pageSize").toString());
        PageHelper.startPage(pageIndex,pageSize);
        Page<${entityClassName}> result = (Page) ${mapperVarName}.selectWithPage(map);
        Map<String,Object> resultMap = new LinkedHashMap<>();
        resultMap.put("pageIndex",pageIndex);
        resultMap.put("pageSize",pageSize);
        resultMap.put("total",result.getTotal());
        resultMap.put("result",result.getResult());
        return resultMap ;
    }

    public ${entityClassName} getByPrimaryKey(${primaryKey.type} ${primaryKey.varName}){
        return ${mapperVarName}.getByPrimaryKey(${primaryKey.varName});
    }

    public int update(${entityClassName} ${localVarName}){
        return ${mapperVarName}.update(${localVarName});
    }

    public int insert(${entityClassName} ${localVarName}){
        return ${mapperVarName}.insert(${localVarName});
    }

    public int saveOrUpdate(${entityClassName} ${localVarName}){
        return ${mapperVarName}.saveOrUpdate(${localVarName});
    }
    public int delete(${primaryKey.type} ${primaryKey.varName}){
        return ${mapperVarName}.delete(${primaryKey.varName});
    }

}